<?php

namespace app\common\service;

use think\Db;

class InvestService{

	//激活判断
	public static function isActive($uid){
		$data = Db::table('tp_invest_record')->where('uid',$uid)->find()?1:0;
		return $data;
	}

	/*
  	下级节点左右区状态
  	*/
  	public static function downStatus($user_id,$username,$position,$jdid,$depth,$active,$sj_active){
		$data = [
			'user_id'  => $user_id,
            'username' => $username,
            // 'phone'    => '',
            'position' => $position,
            'jdid'     => $jdid,
            'depth'    => $depth,
            'active'   => $active,
            'sj_active'=> $sj_active,
		];
    	return $data;
  	}


    /*
    获取全部下级
     */
    public static function getAllXid($uid){
        $data = [];
        $uids = [];
        $i = 0;
        while ($uid) {
            $uid = Db::table('tp_user')->where('jdid','in',$uid)->column('id');
            if ($uid) {
                $uids = array_merge($uids,$uid);
                $i += 1;
            }
        }
        $data['uids']   = $uids;
        $data['depth'] = $i;
        return $uids;
    }
}